<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup sla-policy" [lvLabelColon]="false">
    <lv-form-item>
        <lv-form-label>{{'common_retention_policy_label' | i18n}}</lv-form-label>
        <lv-form-control>
            <lv-radio-group formControlName="retention_type" [lvGroupName]="'retentionTypeGroup'">
                <lv-group [lvGutter]="'20px'">
                    <lv-radio [lvValue]="1">
                        {{'protection_persistent_keep_label' | i18n}}
                    </lv-radio>
                    <lv-radio [lvValue]="2">
                        {{'protection_specify_time_keep_label' | i18n}}
                    </lv-radio>
                </lv-group>
            </lv-radio-group>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="formGroup.value.retention_type === 2">
        <lv-form-label lvRequired>
            {{'common_retention_label' | i18n}}
            <i *ngIf="!isCyberEngine" lv-icon="aui-icon-help" lv-tooltip="{{'protection_retention_policy_desc_label' | i18n}}
{{helpTipsLabel}}{{retainedTipLabel}}"  class="configform-constraint" lvColorState='true'>
            </i>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="retentionDurationErrorTip">
            <lv-input-group [lvAddAfter]="unitTpl" class="input-group-select-right">
                <input lv-input formControlName="retention_duration"
                    placeholder="1~{{isArchiveOrRep ? repOrArchiveUnitMap[formGroup.value.duration_unit]:backupUnitMap[formGroup.value.duration_unit]}}" />
            </lv-input-group>
            <ng-template #unitTpl>
                <lv-select [lvOptions]="retentionDurations" formControlName="duration_unit" class="unit-inner-select"
                    lvValueKey="value" (ngModelChange)="changeTimeUnits($event)"></lv-select>
            </ng-template>
        </lv-form-control>
    </lv-form-item>
</lv-form>
